#include <iostream>

#include "src/IOServiceFactory.hpp"
#include "src/ConnectionFactory.hpp"
#include "src/Signal.hpp"
#include "src/Acceptor.hpp"
#include "src/IOServicePool.hpp"
#include "src/Server.hpp"

int main(int argc, char* argv[])
{
	try
	{
		// Initialize the server.
		const std::size_t num_threads = 2;

		IOServiceFactory ioServiceFactory;
		IOServicePool ioServicePool(ioServiceFactory, num_threads);

		Signal signal(ioServicePool.getIoService());
		Acceptor acceptor(ioServicePool.getIoService());
		ConnectionFactory connectionFactory;

		Server s("127.0.0.1", "5223", ioServicePool, signal, acceptor, connectionFactory);

		// Run the server until stopped.
		s.run();
	}
	catch (std::exception& e)
	{
		std::cerr << "exception: " << e.what() << "\n";
	}

	return 0;
}